1 00:00:00,540 --> 00:00:05,100 In this video, I'm going to modify a part size and position with the script. 2 00:00:05,100 --> 00:00:11,070 So I'm going to introduce a new row box data type called a vector three vector threes are great for 3 00:00:11,070 --> 00:00:12,330 holding three numbers. 4 00:00:12,330 --> 00:00:14,340 Let's go ahead and see how that's done. 5 00:00:14,340 --> 00:00:18,840 I have my first game right here because it's convenient. 6 00:00:18,840 --> 00:00:21,990 You can go ahead and get a fresh world, but make sure there's a part in it. 7 00:00:21,990 --> 00:00:28,290 If there is a part in it, open that part up and then disable any scripts that we might have done from 8 00:00:28,290 --> 00:00:29,100 other videos. 9 00:00:29,100 --> 00:00:31,020 So I'm just going to disable change it. 10 00:00:31,500 --> 00:00:38,910 Let's go to my part and we'll add a script here, but let's take a look at size and position. 11 00:00:38,910 --> 00:00:41,310 I know this is a little bit small, but that's all right. 12 00:00:41,310 --> 00:00:46,680 Go to properties, look for size and position, hit the little arrow and you'll notice there's an X, 13 00:00:46,680 --> 00:00:47,700 Y and Z. 14 00:00:47,700 --> 00:00:52,410 That is for the length, the height and the width, right? 15 00:00:52,410 --> 00:00:53,670 X, Y and Z. 16 00:00:53,700 --> 00:00:56,970 If you want to know which is which, you'll have a little x right here. 17 00:00:57,180 --> 00:01:01,380 It's hard to see the key there, a z, and then the Y is the up and down. 18 00:01:01,380 --> 00:01:05,820 So that's a little key on where your X, Y and Z is and which way you're going. 19 00:01:06,150 --> 00:01:12,270 If we look at position, we have this crazy decimal number here for X and Z because we just plopped 20 00:01:12,270 --> 00:01:13,170 it in the world. 21 00:01:13,200 --> 00:01:19,920 10.5 is the height, the terrain is ten studs height, and then the block is one stud. 22 00:01:19,920 --> 00:01:22,380 So halfway through is the position. 23 00:01:22,380 --> 00:01:24,780 The position is going to be in the center of the part. 24 00:01:25,200 --> 00:01:28,860 So this is touching the ground if we move our Z. 25 00:01:28,890 --> 00:01:30,030 Let's go ahead and take a look at that. 26 00:01:30,030 --> 00:01:35,340 We have a -13.305 or something, something kind of crazy. 27 00:01:35,340 --> 00:01:37,900 Let's make it a zero boom. 28 00:01:38,160 --> 00:01:40,080 We just moved it along the Z. 29 00:01:40,080 --> 00:01:41,010 See, there's your Z. 30 00:01:41,580 --> 00:01:42,390 Cool. 31 00:01:42,840 --> 00:01:45,180 Let's go ahead and do that with a script, though. 32 00:01:46,810 --> 00:01:50,140 All right, so on my part, let's hit the little plus sign. 33 00:01:50,150 --> 00:01:50,680 Boom! 34 00:01:50,710 --> 00:01:51,610 Open it up. 35 00:01:51,700 --> 00:01:57,820 I had a script and that in the script, let's say let's call this move it. 36 00:01:58,000 --> 00:02:00,040 We're actually going to move it and change the size. 37 00:02:00,040 --> 00:02:04,940 But the script is descriptive enough so you know how to find it if you need to. 38 00:02:04,960 --> 00:02:06,370 And we only have four scripts. 39 00:02:06,550 --> 00:02:14,760 Let's get rid of that print and then we'll do a local part equals script. 40 00:02:15,310 --> 00:02:18,240 So we just got a variable for our part. 41 00:02:18,250 --> 00:02:19,250 There's a script. 42 00:02:19,270 --> 00:02:20,280 There's the parent. 43 00:02:20,290 --> 00:02:22,720 My part is sitting right in there. 44 00:02:23,170 --> 00:02:24,010 All right. 45 00:02:24,010 --> 00:02:29,800 Let's go ahead and wait 6 seconds, because we're going to change the position of our part and we want 46 00:02:29,800 --> 00:02:30,340 to see it. 47 00:02:30,340 --> 00:02:32,910 And it takes a little bit of time for the game to start up. 48 00:02:32,920 --> 00:02:34,300 We don't want to miss it. 49 00:02:34,690 --> 00:02:35,860 Let's get our part. 50 00:02:35,950 --> 00:02:37,870 Dot position. 51 00:02:38,500 --> 00:02:39,450 There it is. 52 00:02:39,460 --> 00:02:40,570 I put a P there. 53 00:02:40,600 --> 00:02:41,770 There's position. 54 00:02:42,070 --> 00:02:43,300 What is position? 55 00:02:43,330 --> 00:02:44,370 Check this out. 56 00:02:44,380 --> 00:02:49,960 If we do that p again hit position, we see this vector three. 57 00:02:49,960 --> 00:02:51,090 Oh, it's giving us a hint. 58 00:02:51,100 --> 00:02:52,060 That's the data type. 59 00:02:52,090 --> 00:02:54,210 That's the data type we need factor three. 60 00:02:54,250 --> 00:02:55,660 Hold three numbers. 61 00:02:55,660 --> 00:02:58,180 We need three numbers an, x, y and Z. 62 00:02:58,270 --> 00:03:04,750 We had vector three on this side of the plus sign or the equal sign enter new. 63 00:03:04,780 --> 00:03:08,500 We are instantiating a new vector three. 64 00:03:08,500 --> 00:03:10,090 That's the fancy way of saying it. 65 00:03:10,090 --> 00:03:11,590 So we're creating a vector three. 66 00:03:12,310 --> 00:03:13,840 That's the normal way of saying it. 67 00:03:14,620 --> 00:03:15,940 How shall we move this? 68 00:03:15,970 --> 00:03:17,050 It was something crazy. 69 00:03:17,050 --> 00:03:19,600 It was like we had our part. 70 00:03:19,630 --> 00:03:20,550 Let's take a look. 71 00:03:20,560 --> 00:03:24,070 Position was 26 point something. 72 00:03:24,100 --> 00:03:25,150 10.5. 73 00:03:25,150 --> 00:03:26,320 And we made that last. 74 00:03:26,320 --> 00:03:28,120 That last value is zero. 75 00:03:28,150 --> 00:03:32,680 Let's make it 40 studs on the x 10.5. 76 00:03:32,680 --> 00:03:34,120 We're going to keep it the same height. 77 00:03:34,150 --> 00:03:36,010 Keep it the same Z. 78 00:03:36,520 --> 00:03:37,630 Let's see what we got. 79 00:03:38,020 --> 00:03:39,550 Let's go to my first game. 80 00:03:40,820 --> 00:03:41,840 Hit play. 81 00:03:43,510 --> 00:03:44,740 And watch it move. 82 00:03:47,880 --> 00:03:48,570 BO. 83 00:03:48,960 --> 00:03:51,180 That was that was kind of cool. 84 00:03:51,840 --> 00:03:53,730 Let's let's make a move some more, though. 85 00:03:54,120 --> 00:03:55,110 We'll hit the stop. 86 00:03:56,290 --> 00:03:57,190 Mauve. 87 00:03:58,030 --> 00:03:59,080 And then we'll get this. 88 00:04:00,190 --> 00:04:02,680 Let's get these two lines. 89 00:04:03,190 --> 00:04:08,920 You can do a control C to copy or you use the mouse right click and then use the menu. 90 00:04:08,950 --> 00:04:11,590 I'm going to do a control V to paste. 91 00:04:12,160 --> 00:04:16,040 Let me make this one second and let's see. 92 00:04:16,060 --> 00:04:18,550 Let's make this 30. 93 00:04:18,580 --> 00:04:19,310 There we go. 94 00:04:19,330 --> 00:04:20,050 30. 95 00:04:21,010 --> 00:04:22,200 Let's do that a couple of times. 96 00:04:22,210 --> 00:04:25,410 I still have those two lines of code in my my buffer. 97 00:04:25,420 --> 00:04:30,480 I'm going to do a control v control v control v. 98 00:04:30,490 --> 00:04:32,540 We'll move it a few times. 99 00:04:32,560 --> 00:04:33,220 Let's see. 100 00:04:33,220 --> 00:04:35,470 We got let's make this one second. 101 00:04:36,670 --> 00:04:39,460 And then we'll go to 20. 102 00:04:39,970 --> 00:04:40,960 Cool. 103 00:04:40,990 --> 00:04:43,330 Let's do one second. 104 00:04:44,330 --> 00:04:46,010 We'll go to. 105 00:04:47,290 --> 00:04:48,820 20 again. 106 00:04:48,820 --> 00:04:54,010 Should we do 20 again and then maybe change the Z a little bit? 107 00:04:54,160 --> 00:04:56,770 Let's change the Z to like. 108 00:04:57,690 --> 00:04:58,470 Ten. 109 00:04:59,730 --> 00:05:00,120 All right. 110 00:05:00,120 --> 00:05:01,170 And then. 111 00:05:02,840 --> 00:05:04,460 Let's do something a little different. 112 00:05:04,460 --> 00:05:05,480 Like with a height. 113 00:05:05,630 --> 00:05:08,160 Let's go one second and then the height. 114 00:05:08,180 --> 00:05:11,120 Let's move this up to studs. 115 00:05:11,450 --> 00:05:13,310 But we'll keep in the same position. 116 00:05:13,310 --> 00:05:17,990 We'll do 20 12.5 and it's supposed to be a ten. 117 00:05:18,920 --> 00:05:19,550 Cool. 118 00:05:19,550 --> 00:05:21,140 Let's see what we got. 119 00:05:28,490 --> 00:05:29,440 There we go. 120 00:05:29,450 --> 00:05:30,470 There we go. 121 00:05:30,620 --> 00:05:31,430 Yeah. 122 00:05:33,120 --> 00:05:34,360 On it fell. 123 00:05:34,380 --> 00:05:36,600 Did you see how it went up and then it fell? 124 00:05:37,380 --> 00:05:38,850 Well, we can fix that. 125 00:05:38,940 --> 00:05:40,830 We can anchor this part. 126 00:05:41,100 --> 00:05:43,910 Anchoring a part will do control. 127 00:05:44,200 --> 00:05:45,600 Just move that anchor. 128 00:05:45,630 --> 00:05:51,030 Anchoring a part will prevent your part from moving from game objects in the game. 129 00:05:51,030 --> 00:05:53,280 But you can still move it with a script. 130 00:05:53,310 --> 00:05:54,600 You need to know that. 131 00:05:54,630 --> 00:06:00,750 Let's go ahead and anchor this so that when we move it, the game forces won't take over like gravity 132 00:06:00,750 --> 00:06:02,610 pulling it down once we move it up. 133 00:06:03,150 --> 00:06:04,710 Hit that little checkbox. 134 00:06:04,710 --> 00:06:05,820 Hit play. 135 00:06:05,820 --> 00:06:07,320 And then watch our part. 136 00:06:09,690 --> 00:06:11,190 It's going to be pretty exciting. 137 00:06:11,670 --> 00:06:16,620 One, two, three, four, up. 138 00:06:16,650 --> 00:06:17,370 Look at that. 139 00:06:17,380 --> 00:06:18,730 It's just hanging in the air. 140 00:06:18,750 --> 00:06:21,390 You can make a staircase with code. 141 00:06:22,300 --> 00:06:23,660 Oh, man. 142 00:06:23,680 --> 00:06:24,270 Cool. 143 00:06:24,280 --> 00:06:27,610 Let's change the size just so you get a feel for that. 144 00:06:28,090 --> 00:06:29,500 This is our spawn location. 145 00:06:29,500 --> 00:06:30,280 We can move that. 146 00:06:30,310 --> 00:06:30,940 There we go. 147 00:06:31,820 --> 00:06:34,460 Good to move it and let's change the size now. 148 00:06:35,060 --> 00:06:37,040 Control C to copy. 149 00:06:37,280 --> 00:06:39,230 Control V to paste. 150 00:06:40,160 --> 00:06:44,330 This is going to be size or that size. 151 00:06:44,330 --> 00:06:47,100 Size also wants a vector three. 152 00:06:47,120 --> 00:06:48,910 The IntelliSense is up here. 153 00:06:48,920 --> 00:06:50,420 Let's just go ahead and click it. 154 00:06:50,840 --> 00:06:51,950 I was kind of hard to read. 155 00:06:51,950 --> 00:06:53,900 I no remember our size. 156 00:06:53,900 --> 00:07:00,260 Now, if we click click our my part, let's look at size is four one and two. 157 00:07:00,260 --> 00:07:02,720 So we don't want to make it this big. 158 00:07:02,720 --> 00:07:08,960 Let's make it four, four and four. 159 00:07:09,710 --> 00:07:12,170 Sweet play. 160 00:07:12,560 --> 00:07:13,760 It's going to be exciting. 161 00:07:18,630 --> 00:07:22,440 One, two, three, four. 162 00:07:22,740 --> 00:07:23,580 Boom! 163 00:07:23,910 --> 00:07:24,730 Oh, look at that. 164 00:07:24,740 --> 00:07:25,980 That made it big. 165 00:07:26,010 --> 00:07:27,390 That's kind of cool. 166 00:07:27,600 --> 00:07:28,080 All right. 167 00:07:28,080 --> 00:07:35,490 So one other thing I want to show you is we have other values that hold vector threes. 168 00:07:35,520 --> 00:07:40,920 In particular, we have orientation, which affects the rotation of the object. 169 00:07:40,920 --> 00:07:45,390 And these Z, the X, Y and Z is going to be the axes of rotation. 170 00:07:45,390 --> 00:07:46,740 This will be in degrees. 171 00:07:46,740 --> 00:07:50,130 We're going to go over that with our rotating coin. 172 00:07:50,130 --> 00:07:55,320 I have a rotating coin, one I also want to show you in the browser. 173 00:07:55,350 --> 00:07:57,300 I'll put this link in the description. 174 00:07:57,450 --> 00:08:05,010 You can go ahead and take a look at ROBLOX engine data types, ROBLOX Engine data types and vector three 175 00:08:05,010 --> 00:08:08,160 is down here, so you can read more about it. 176 00:08:08,160 --> 00:08:13,170 It's good to start looking at the documentation because you can't always find everything in a video. 177 00:08:13,170 --> 00:08:16,890 So with that I will see you in the next video.